home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Dev / misc / WHDLoad_dev.lha / WHDLoad / Src / slave-examples / oscar.asm < prev    next >
Encoding:
Assembly Source File  |  2003-12-09  |  8.5 KB  |  383 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    oscar.asm
  3. ;  :Contents.    Slave for "Oscar"
  4. ;  :Author.    wepl <wepl@whdload.de>
  5. ;  :Original.    v1 Desktop Dynamite <wepl@whdload.de>
  6. ;        v2
  7. ;        v3 CD³²
  8. ;        v4 CD³² Diggers Bundle
  9. ;  :Version.    $Id: oscar.asm 1.14 2003/12/09 11:15:06 wepl Exp wepl $
  10. ;  :History.    20.05.96
  11. ;        16.06.97 updated for slave version 2
  12. ;        15.08.97 update for key managment
  13. ;        15.07.98 cache on 68040+ disabled
  14. ;        08.05.99 adapted for WHDLoad 10.0, access faults removed
  15. ;        08.12.99 support for v2 added
  16. ;        16.01.00 support for v3 added
  17. ;        23.02.01 support for v4 added, underwater bug fixed
  18. ;        26.03.02 decruncher moved to fastmem
  19. ;  :Requires.    -
  20. ;  :Copyright.    Public Domain
  21. ;  :Language.    68000 Assembler
  22. ;  :Translator.    Barfly V2.9
  23. ;  :To Do.
  24. ;---------------------------------------------------------------------------*
  25.  
  26.     INCDIR    Includes:
  27.     INCLUDE    whdload.i
  28.     INCLUDE    whdmacros.i
  29.     INCLUDE    libraries/lowlevel.i
  30.  
  31.     IFD BARFLY
  32.     OUTPUT    "wart:o/oscar/Oscar.Slave"
  33.     BOPT    O+                ;enable optimizing
  34.     BOPT    OG+                ;enable optimizing
  35.     BOPT    ODd-                ;disable mul optimizing
  36.     BOPT    ODe-                ;disable mul optimizing
  37.     BOPT    w4-                ;disable 64k warnings
  38.     SUPER                    ;disable supervisor warnings
  39.     ENDC
  40.  
  41.     STRUCTURE    globals,$100
  42.         LONG    _resload
  43.         LONG    _chipptr
  44.         LONG    _clist
  45.         BYTE    _decinit
  46.  
  47. ;============================================================================
  48.  
  49. _base        SLAVE_HEADER            ;ws_Security + ws_ID
  50.         dc.w    10            ;ws_Version
  51.         dc.w    WHDLF_NoError        ;ws_flags
  52. _upchip        dc.l    $181000            ;ws_BaseMemSize 
  53.                         ;floppy vers need only $177000
  54.         dc.l    0            ;ws_ExecInstall
  55.         dc.w    _Start-_base        ;ws_GameLoader
  56.         dc.w    _data-_base        ;ws_CurrentDir
  57.         dc.w    0            ;ws_DontCache
  58. _keydebug    dc.b    0            ;ws_keydebug
  59. _keyexit    dc.b    $59            ;ws_keyexit = F10
  60. _expmem        dc.l    $1000            ;ws_ExpMem
  61.         dc.w    _name-_base        ;ws_name
  62.         dc.w    _copy-_base        ;ws_copy
  63.         dc.w    _info-_base        ;ws_info
  64.  
  65. ;============================================================================
  66.  
  67.     IFD BARFLY
  68.     IFND    .passchk
  69.     DOSCMD    "WDate  >T:date"
  70. .passchk
  71.     ENDC
  72.     ENDC
  73.  
  74. _data        dc.b    "data",0
  75. _name        dc.b    "Oscar",0
  76. _copy        dc.b    "1993 Flair Software",0
  77. _info        dc.b    "installed & fixed by Wepl",10
  78.         dc.b    "version 1.8 "
  79.     IFD BARFLY
  80.         INCBIN    "T:date"
  81.     ENDC
  82.         dc.b    0
  83.     EVEN
  84.  
  85. ;============================================================================
  86. _Start        ;    A0 = resident loader
  87. ;============================================================================
  88.  
  89.     ;save resload base
  90.         move.l    a0,(_resload)            ;save
  91.         move.l    a0,a5                ;A5 = resload
  92.         sf    (_decinit)            ;decruncher not init
  93.  
  94.     ;set stackpointers
  95.         move.l    (_expmem),a7
  96.         add.w    #$ff0,a7
  97.         lea    (-$400,a7),a0
  98.         move    a0,usp
  99.  
  100.     ;set start address for emulated exec.AllocMem
  101.         move.l    #$400,(_chipptr)
  102.  
  103.     ;load main
  104.         lea    (_exe,pc),a0            ;name
  105.         move.l    (_chipptr),a1            ;address
  106.         move.l    a1,a4                ;A4 = executable
  107.         jsr    (resload_LoadFileDecrunch,a5)
  108.     ;relocate main
  109.         move.l    a4,a0                ;address
  110.         sub.l    a1,a1                ;taglist
  111.         jsr    (resload_Relocate,a5)
  112.         add.l    d0,(_chipptr)
  113.     ;check version & apply patches
  114.         lea    (_pexe1,pc),a0            ;patchlist
  115.         cmp.l    #$2f2d4,d0
  116.         beq    .patch
  117.         lea    (_pexe2,pc),a0            ;patchlist
  118.         cmp.l    #$2cf58,d0
  119.         beq    .patch
  120.         lea    (_pexe3,pc),a0            ;patchlist
  121.         cmp.l    #$a80d8,d0
  122.         beq    .patch
  123.         lea    (_pexe4,pc),a0            ;patchlist
  124.         cmp.l    #$300a0,d0
  125.         beq    .patch
  126.         pea    TDREASON_WRONGVER
  127.         jmp    (resload_Abort,a5)
  128.         
  129. .patch        move.l    a4,a1                ;address
  130.         jsr    (resload_Patch,a5)
  131.  
  132.     ;init ints
  133.         lea    (_vbi,pc),a0
  134.         move.l    a0,($6c)
  135.         bsr    _SetupKeyboard            ;required for cd versions
  136.  
  137.     ;init dma
  138.         lea    (_clist),a0
  139.         move.l    #-2,(a0)
  140.         move.l    a0,(_custom+cop1lc)
  141.  
  142.     ;start main
  143.         move    #0,sr
  144.         jmp    ($3e,a4)
  145.  
  146. _pexe1        PL_START
  147.         PL_P    $8b4e,_allocmem            ;emulate
  148.         PL_S    $276,$2a8-$276            ;disable os-stuff
  149.         PL_P    $7b1a,_loader
  150.         PL_PS    $8dfc,_decrunch
  151.         PL_W    $1ce2,$e841            ;lsr.w  -> asr.w
  152.         PL_W    $1ce4,$c3fc            ;mulu   -> muls
  153.         PL_W    $1cfc,$d0c1            ;adda.l -> adda.w
  154.         PL_W    $1e0e,$e841            ;lsr.w  -> asr.w
  155.         PL_W    $1e10,$c3fc            ;mulu   -> muls
  156.         PL_W    $1e28,$d0c1            ;adda.l -> adda.w
  157.         PL_S    $9764,$99fc-$9764        ;copylock
  158.         PL_PS    $23fa2,_dbf1
  159.         PL_PS    $23fb8,_dbf1
  160.         PL_PS    $246e2,_dbf1
  161.         PL_PS    $246f8,_dbf1
  162.         PL_PS    $2558a,_dbf2
  163.         PL_PS    $255ee,_dbf2
  164.         PL_END
  165.  
  166. _pexe2        PL_START
  167.         PL_P    $8b56,_allocmem            ;emulate
  168.         PL_S    $276,$2a8-$276            ;disable os-stuff
  169.         PL_P    $7b22,_loader
  170.         PL_PS    $8e04,_decrunch
  171.         PL_W    $1cbc,$e841            ;lsr.w  -> asr.w
  172.         PL_W    $1cbe,$c3fc            ;mulu   -> muls
  173.         PL_W    $1cd6,$d0c1            ;adda.l -> adda.w
  174.         PL_W    $1de8,$e841            ;lsr.w  -> asr.w
  175.         PL_W    $1dea,$c3fc            ;mulu   -> muls
  176.         PL_W    $1e02,$d0c1            ;adda.l -> adda.w
  177.         PL_S    $976c,$9a04-$976c        ;copylock
  178.         PL_PS    $21c26,_dbf1
  179.         PL_PS    $21c3c,_dbf1
  180.         PL_PS    $22366,_dbf1
  181.         PL_PS    $2237c,_dbf1
  182.         PL_PS    $2320e,_dbf2
  183.         PL_PS    $23272,_dbf2
  184.         PL_END
  185.  
  186. _pexe3        PL_START
  187.         PL_P    $76fc,_allocmem            ;emulate
  188.         PL_S    $200,$254-$200            ;disable os-stuff
  189.     ;    PL_W    $b48e,$4e73            ;jmp to org vbi -> rte
  190.         PL_S    $750e,$86-$e            ;skip os-restore
  191.         PL_S    $75a8,10            ;skip open
  192.         PL_PS    $75de,_loadercd
  193.         PL_S    $7630,14+$14            ;skip os-save
  194.         PL_PS    $330,_enabledma
  195.         PL_W    $199c,$e841            ;lsr.w  -> asr.w
  196.         PL_W    $199e,$c3fc            ;mulu   -> muls
  197.         PL_W    $19b0,$d0c1            ;adda.l -> adda.w
  198.         PL_W    $1ac2,$e841            ;lsr.w  -> asr.w
  199.         PL_W    $1ac4,$c3fc            ;mulu   -> muls
  200.         PL_W    $1ad6,$d0c1            ;adda.l -> adda.w
  201.         PL_PS    $2d8fc,_dbf1
  202.         PL_PS    $2d912,_dbf1
  203.         PL_PS    $2e03c,_dbf1
  204.         PL_PS    $2e052,_dbf1
  205.         PL_PS    $2eed2,_dbf2
  206.         PL_PS    $2ef36,_dbf2
  207.         PL_END
  208.  
  209. _pexe4        PL_START
  210.         PL_S    $3e,$b4-$3e            ;skip os
  211.         PL_PS    $b4,_getlang
  212.         PL_P    $89ec,_allocmem            ;emulate
  213.         PL_S    $2e0,$326-$2e0            ;disable os-stuff
  214.         PL_S    $797a,$cc-$7a            ;skip os-restore
  215.         PL_S    $79ee,10            ;skip open
  216.         PL_PS    $7a24,_loadercd
  217.         PL_S    $7a54,$68-$54            ;skip os-save
  218.         PL_W    $1ccc,$e841            ;lsr.w  -> asr.w
  219.         PL_W    $1cce,$c3fc            ;mulu   -> muls
  220.         PL_W    $1ce6,$d0c1            ;adda.l -> adda.w
  221.         PL_W    $1df8,$e841            ;lsr.w  -> asr.w
  222.         PL_W    $1dfa,$c3fc            ;mulu   -> muls
  223.         PL_W    $1e12,$d0c1            ;adda.l -> adda.w
  224.         PL_R    $b5c0                ;cd.device
  225.         PL_R    $b614                ;cd.device
  226.         PL_PS    $afe2,_readjoy            ;lowlevel.ReadJoyPort
  227.     ;    PL_PS    $b01e,_readjoy            ;lowlevel.ReadJoyPort
  228.     ;    PL_PS    $b03e,_readjoy            ;lowlevel.ReadJoyPort
  229.     ;    PL_PS    $b060,_readjoy            ;lowlevel.ReadJoyPort
  230.         PL_PS    $22e0c,_dbf1
  231.         PL_PS    $22e22,_dbf1
  232.         PL_PS    $2354c,_dbf1
  233.         PL_PS    $23562,_dbf1
  234.         PL_PS    $243f4,_dbf2
  235.         PL_PS    $24458,_dbf2
  236.         PL_END
  237.  
  238. ;--------------------------------
  239.  
  240. _getlang    clr.l    -(a7)
  241.         clr.l    -(a7)
  242.         pea    WHDLTAG_LANG_GET
  243.         move.l    a7,a0
  244.         move.l    (_resload),a1
  245.         jsr    (resload_Control,a1)
  246.         addq.l    #4,a7
  247.         move.l    (a7)+,d0
  248.         addq.l    #4,a7
  249.         rts
  250.  
  251. ;--------------------------------
  252.  
  253. _dbf2
  254. _dbf1        movem.l    d0-d1,-(a7)
  255.         moveq    #8,d1
  256. .1        move.b    ($dff006),d0
  257. .2        cmp.b    ($dff006),d0
  258.         beq    .2
  259.         dbf    d1,.1
  260.         movem.l    (a7)+,d0-d1
  261.         addq.l    #2,(a7)
  262.         rts
  263.  
  264. ;--------------------------------
  265.  
  266. _vbi        move.w    #INTF_VERTB,(_custom+intreq)
  267.         rte
  268.  
  269. ;--------------------------------
  270.  
  271. _allocmem    addq.l    #7,d0                ;round up
  272.         and.b    #$f8,d0
  273.  
  274.         move.l    (_chipptr),a1
  275.         add.l    d0,(_chipptr)
  276.     IFEQ 1
  277.         move.l    (_chipptr),d1
  278.         cmp.l    (_upchip,pc),d1
  279.         blo    .0
  280.         illegal
  281. .0
  282.     ENDC
  283.         move.l    a1,a0
  284.         lsr.l    #3,d0
  285. .clr        clr.l    (a0)+
  286.         clr.l    (a0)+
  287.         subq.l    #1,d0
  288.         bne    .clr
  289.         move.l    a1,d0
  290.         rts
  291.  
  292. ;--------------------------------
  293.  
  294. _loader        addq.l    #4,a0                ;skip "df0:"
  295.         move.l    a2,-(a7)
  296.         move.l    (_resload),a2
  297.         jsr    (resload_LoadFileDecrunch,a2)
  298.         move.l    (a7)+,a2
  299.         moveq    #0,d0                ;return code
  300.         rts
  301.  
  302. _decrunch    bset    #0,(_decinit)
  303.         bne    .initok
  304.         movem.l    d0/a0-a1,-(a7)
  305.         move.l    (12,a7),a0
  306.         move.l    (_expmem,pc),a1
  307.         move.w    #($9266-$8e02)/4-1,d0
  308. .cp        move.l    (a0)+,(a1)+
  309.         dbf    d0,.cp
  310.         move.l    (_resload),a0
  311.         jsr    (resload_FlushCache,a0)
  312.         movem.l    (a7)+,d0/a0-a1
  313.  
  314. .initok        addq.l    #4,a7
  315.         cmp.l    #"TSM!",(a0)
  316.         bne    .rts
  317.  
  318.         movem.l    d0-d7/a0-a6,-(a7)
  319.         addq.l    #4,a0
  320.         move.l    (_expmem,pc),-(a7)
  321. .rts        rts
  322.  
  323. _loadercd    addq.l    #6,a0                ;skip "Oscar:"
  324.         move.l    d2,a1
  325.         move.l    (_resload),a2
  326.         jsr    (resload_LoadFileDecrunch,a2)
  327.         add.l    #14,(a7)
  328.         rts
  329.  
  330. ;--------------------------------
  331.  
  332. _enabledma    move.w    #$c028,(intena,a6)
  333.         waitvb    a6
  334.         move.w    #$86e0!DMAF_RASTER,(dmacon,a6)
  335.         rts
  336.  
  337. ;--------------------------------
  338.  
  339. _readjoy    move.l    d2,-(a7)
  340.  
  341.         moveq    #0,d0
  342.         btst    #7,$bfe001
  343.         bne    .1
  344.         bset    #JPB_BUTTON_RED,d0
  345. .1        move.w    _custom+potinp,d1
  346.         btst    #14,D1
  347.         bne    .2
  348.         bset    #JPB_BUTTON_BLUE,d0
  349. .2
  350.         move.w    _custom+joy1dat,d1
  351.         move.w    d1,d2
  352.         btst    #1,d1
  353.         beq    .left_off
  354.         bset    #JPB_JOY_RIGHT,d0
  355.         bra    .vert_test
  356. .left_off    btst    #9,d1
  357.         beq    .vert_test
  358.         bset    #JPB_JOY_LEFT,d0
  359. .vert_test    lsr.w    #1,d1
  360.         eor.w    d2,d1
  361.         btst    #0,d1
  362.         beq    .back_off
  363.         bset    #JPB_JOY_DOWN,d0
  364.         bra    .exit
  365. .back_off    btst    #8,d1
  366.         beq    .exit
  367.         bset    #JPB_JOY_UP,d0
  368. .exit
  369.         move.l    (a7)+,d2
  370.         rts
  371.  
  372. ;--------------------------------
  373.  
  374. _exe        dc.b    "exe",0
  375.  
  376. ;============================================================================
  377.  
  378.         INCLUDE    sources:whdload/keyboard.s
  379.  
  380. ;============================================================================
  381.  
  382.     END
  383.